
package it.csttech.date;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.glassfish.jersey.server.ParamException;

/**
 * This class is meant to map the ParamException into a Response
 * 
 * @author marcello.felappi
 * @author marco.dalena
 */
@Provider
public class ParamExceptionMapper implements ExceptionMapper<ParamException> {

	/**
	 * This methods is used to translate a ParamException into a BadRequest
	 * response with a json as entity representing a summary of the exception
	 * 
	 * @param param
	 *            - ParamException catched by the exception mapper
	 * @return the response representnig the thrown exception
	 */
	@Override
	public Response toResponse(ParamException param) {

		return Response.status(400).entity(new ErrorObject(param)).build();
	}

}
